const App=getApp()
const httpRequest=require('../../utils/httpRequest.js')

Component({
  properties: {
    reviews: {
      type: Array,
      value: [],
      Token:''
    }
  },

  methods: {
    handleLike(e) {
      const index = e.currentTarget.dataset.index;
      let reviews = this.data.reviews;
      let review = reviews[index];
      review.liked = 1-review.liked;
      review.likeCount = review.liked==1 ? review.likeCount + 1 : review.likeCount - 1;
      this.setData({
        reviews: reviews
      });
      const userToken = wx.getStorageSync('userToken'); 
      httpRequest.Request('Post',App.globalData.backend_add+'api/comments/like?id='+review.id,{},{'Authorization': userToken ,"content-type": "application/json"},'null','null',this)

    }
  }
});
